<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>添加/修改通知公告</title>
<link
	href="<%=request.getContextPath()%>/views/sysdefault/css/bootstrap.min.css?v=3.3.5"
	rel="stylesheet">
<link
	href="<%=request.getContextPath()%>/views/sysdefault/css/font-awesome.min.css?v=4.4.0"
	rel="stylesheet">
<link
	href="<%=request.getContextPath()%>/views/sysdefault/css/animate.min.css"
	rel="stylesheet">
<link
	href="<%=request.getContextPath()%>/views/sysdefault/css/style.min.css?v=4.0.0"
	rel="stylesheet">
<link
	href="<%=request.getContextPath()%>/views/sysdefault/css/plugins/toastr/toastr.min.css"
	rel="stylesheet">

<link
	href="<%=request.getContextPath()%>/views/sysdefault/css/plugins/iCheck/custom.css"
	rel="stylesheet">

</head>

<body class="gray-bg">

	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<!-- <h5>添加/修改通知公告</h5>
						<div class="ibox-tools">
							<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
							</a>
						</div> -->
						<ul class="nav nav-tabs">
								<li class="active"><a data-toggle="tab" href="#tab-1"><i
										class="fa fa-user"></i>通知公告</a></li>
						</ul>
					</div>

					<div class="ibox-content">

						<form action="<%=request.getContextPath()%>/bgPortGlutNotice/addNotice.do" id="subForm" method="post" class="form-horizontal"
							onsubmit="return beforeSub();" enctype="multipart/form-data">
							
							<input type="hidden" id="noticeId" name="noticeId" value="${notice.noticeId}" />
							<div class="tab-content">
							
							<!-- *************新闻tab页**************** -->
								<div id="tab-1" class="tab-pane active">
									<div class="full-height-scroll">
										<div class="form-group">
											<label class="col-sm-1 control-label">标题：</label>
											<div class="col-sm-11">
												<input type="text" id="title" name="keyWord" placeholder="请输入标题，建议在20字以内。"  class="form-control" required=""
												onkeyup="javascript:setShowLength(this, 30, 'cost_tpl_title_length');" maxlength="30"  value="${notice.keyWord}">
												<span class="red" id="cost_tpl_title_length">还可以输入30个字符</span> 
											</div>
										</div>
										
										<div class="form-group">
											<label class="col-sm-1 control-label">通知公告推广：</label>
											<div class="col-sm-10">
												<label class="checkbox-inline i-checks">
												     <input type="checkbox" id="up" name="stick" value="1" <c:if test="${notice.stick == '1'}">checked="true"</c:if>>置顶
												</label>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-1 control-label">通知公告正文：</label>
											<div class="col-sm-11">
												<script id="editor" name="content" type="text/plain" style="height:600px;">${notice.content}</script>
											</div>
										</div>
									</div>
								</div>
							</div>



							<div class="hr-line-dashed"></div>
							<div class="form-group">
								<div class="col-sm-12">
									<button class="btn btn-primary pull-right m-t-n-xs" id="save" type="submit">发布</button>
									<button style="margin-right: 10px;" class="btn btn-warning pull-right m-t-n-xs" onclick="drafts();" >保存至草稿箱</button>
								</div>
							</div>
						</form>

					</div>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		//var fileUploadIp = $("#fileUploadIp").val();
		window.UEDITOR_UPLOAD_URL = '<%=request.getAttribute("fileUploadIp")%>';
	</script>

	<script src="<%=request.getContextPath()%>/views/sysdefault/js/jquery.min.js?v=2.1.4"></script>
	<script src="<%=request.getContextPath()%>/views/sysdefault/js/bootstrap.min.js?v=3.3.5"></script>
	<script src="<%=request.getContextPath()%>/views/sysdefault/js/content.min.js?v=1.0.0"></script>
	<script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/toastr/toastr.min.js"></script>
	<script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/layer/layer.js"></script>
	<script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/iCheck/icheck.min.js"></script>
	<script src="<%=request.getContextPath()%>/views/sysdefault/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/views/sysdefault/js/uploadPreview.js"></script>

	<!-- 富文本编辑器 -->
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath()%>/views/sysdefault/plugins/uEditor/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath()%>/views/sysdefault/plugins/uEditor/ueditor.all.min.js"> </script>
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath()%>/views/sysdefault/plugins/uEditor/lang/zh-cn/zh-cn.js"></script>

	<script type="text/javascript">
    
    var basePath = '<%=request.getContextPath()%>';
    
   		var imgId = "";
    	var inputId = "";

		//初始化富文本编辑器
		var ue = UE.getEditor('editor');

		toastr.options = {
			"closeButton" : true,
			"debug" : false,
			"progressBar" : true,
			"positionClass" : "toast-top-left",
			"showDuration" : "400",
			"hideDuration" : "1000",
			"timeOut" : "3000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		}
		
		function setShowLength(obj, maxlength, id) 
		{ 
			var rem = maxlength - obj.value.length; 
			var wid = id; 
			if (rem < 0){ 
				rem = 0; 
			} 
			document.getElementById(wid).innerHTML = "还可以输入" + rem + "个字符"; 
		} 

		//初始化页面
		$(function() {

			//新闻栏目回显
			var typeInfo = $("#typeInfo").val();
			if (typeInfo != '') {
				var typeInfoList = typeInfo.split(',');
				$("input[name='type']").each(function(i, item) {
					var typeVal = $(this).val();
					var type_self = $(this);
					for ( var typeItem in typeInfoList) {
						if (typeInfoList[typeItem] == typeVal) {
							type_self.attr('checked', true);
							return true;
						}
					}
				});
			}

			//新闻封面图片回显
			var imageInfo = $("#imageInfo").val();
			if (imageInfo != '') {
				$("#imgShow_1").attr("src", imageInfo);
				$("#up_img_1").val(imageInfo);
			}

			$(".i-checks").iCheck({
				checkboxClass : "icheckbox_square-green",
				radioClass : "iradio_square-green",
			});

			new uploadPreview({
				UpBtn : "up_img_1",
				DivShow : "imgdiv_1",
				ImgShow : "imgShow_1"
			});
			
			new uploadPreview({
				UpBtn : "up_img_6",
				DivShow : "imgdiv_6",
				ImgShow : "imgShow_6"
			});
			
			new uploadPreview({
				UpBtn : "up_img_7",
				DivShow : "imgdiv_7",
				ImgShow : "imgShow_7"
			});

			//禁止后退键 作用于Firefox、Opera
		    document.onkeypress=banBackSpace;
		    //禁止后退键  作用于IE、Chrome
		    document.onkeydown=banBackSpace;
		});

		var clickImg = function(mInputId, mImgId, imgageCompress) {
			inputId = mInputId;
	    	imgId = mImgId;
	    	
	    	 layer.open({
				  type: 2,
				  title:"上传图片",
				  fix: false, //不固定
				  maxmin: false,
				  shadeClose: true,
				  shade: 0.3,
				  area: ['600px', '430px'],
				  content: basePath + '/common/selectImage.dop?imageCompress='+imgageCompress
				}); 
		}

		//提交表单前校验
		function beforeSub() {
			
			//校验新闻栏目
			var newsAllType = $("input[name='type']");
			if(newsAllType.length > 0){
				var newsType = $("input[name='type']:checked");
				if (newsType.length == 0) {
					toastr.warning("至少选择一个通知公告栏目！", "提示");
					return false;
				}

			}
			
			return true;
		}
		
		
		var drafts = function(){
			document.getElementById("show_status").value = 3;
			document.getElementById("save").click();					
		}
		
		//弹出框选择回调函数
		var selectCallBack2 = function(data){
			debugger;
			var obj = jQuery.parseJSON(data);
			var imgList = obj.image.split(',');
			if(imgList.length > 0){
				$("#" + inputId).val(imgList[0]);
				$("#" + imgId).attr("src" , imgList[0]);
			}
			layer.closeAll();
		}
		
		//处理键盘事件 禁止后退键（Backspace）密码或单行、多行文本框除外
	    function banBackSpace(e){   
	        var ev = e || window.event;//获取event对象   
	        var obj = ev.target || ev.srcElement;//获取事件源   
	        var t = obj.type || obj.getAttribute('type');//获取事件源类型  
	        //获取作为判断条件的事件类型
	        var vReadOnly = obj.getAttribute('readonly');
	        //处理null值情况
	        vReadOnly = (vReadOnly == "") ? false : vReadOnly;
	        //当敲Backspace键时，事件源类型为密码或单行、多行文本的，
	        //并且readonly属性为true或enabled属性为false的，则退格键失效
	        var flag1=(ev.keyCode == 8 && (t=="password" || t=="text" || t=="textarea") 
	                    && vReadOnly=="readonly")?true:false;
	        //当敲Backspace键时，事件源类型非密码或单行、多行文本的，则退格键失效
	        var flag2=(ev.keyCode == 8 && t != "password" && t != "text" && t != "textarea")
	                    ?true:false;        
	        
	        //判断
	        if(flag2){
	            return false;
	        }
	        if(flag1){   
	            return false;   
	        }   
	    }

	</script>

</body>

</html>